<?php
class CommonHelper extends AppHelper {

		/**
	* Fix SQL Injection
	*/
	public $helpers=array('Session');

	
	function columnTitle($title=null,$sortField=null,$params=null,$model=null,$container='listContent',$action='sort'){
		$rt=null;
		if($container==null)$container='listContent';
		if($action==null)$action='sort';
		if(!$model){
			$data=explode('.', $sortField);
			$model=$data[0];		
		}
		if($title!=null && $sortField!=null){
			if($this->Session->read($model.'.sortDir')=='asc'){
				$dir='up';
				$nextSortDir='desc';
			}
			else {
				$dir='down';
				$nextSortDir='asc';
			}
			$rt='<a onclick="ajax(\''.$container.'\',\''.$this->params['controller'].'/'.$action.'/'.$sortField.'/'.$nextSortDir.'/'.$params.'\');return false;" href="#">'.$title.'</a>';
			if($this->Session->read($model.'.sortField')==$sortField){
				$rt.='<img style="margin-bottom:0" border="0" src="'.$this->webroot.'img/backend/'.$dir.'arrow1.png" />';
			}
		}
		return $rt;
	}
	
	function cutText($text, $n=80) { 
		// string is shorter than n, return as is
		if (strlen($text) <= $n) {
			return $text;}
		$text= substr($text, 0, $n);
		if ($text[$n-1] == ' ') {
			return trim($text)."...";
		}
		$x  = explode(" ", $text);
		$sz = sizeof($x);
		if ($sz <= 1)   {
			return $text." ...";}
		$x[$sz-1] = '';
		return trim(implode(" ", $x))." ...";
	}
	
	function ScImage($string, $fact, $bcol, $fcol) { 
		$font = 6;
		$charwidth = imagefontwidth($font); 
		$charheight = imagefontheight($font); 
		$width=(strlen($string)+2)*$charwidth; 
		$height=(1.5)*$charheight; 
	
		$im = @imagecreatetruecolor($width, $height) or die("Cannot Initialize new GD image stream"); 
		$im2 = imagecreatetruecolor($width*$fact, $height*$fact); 
		$bcol = imagecolorallocate($im, $bcol[0], $bcol[1], $bcol[2]); 
		$fcol = imagecolorallocate($im, $fcol[0], $fcol[1], $fcol[2]); 
		$gray = imagecolorallocate($im, 210,210,210);
		
		imagefill($im, 0, 0, $bcol); 
		imagestring($im, $font, $charwidth, $charheight/4, $string, $fcol); 
		imageline($im,5,10,65,10,$gray);
	
		for($i=0; $i<$width*$fact; $i++) { 
			for($j=0; $j<$height*$fact; $j++) { 
				$col = imagecolorat($im, $i, $j); 
				imagesetpixel($im2, $i, $j, $col); 
			} 
		} 
	
		ob_start(); 
		imagepng($im2); 
		header('Content-type: image/png'); 
		ob_end_clean(); 	
		imagedestroy($im); 
		imagedestroy($im2); 
	}
	function create_random_string($num){
		//Tao du lieu cho hinh ngau nhien
		$chars = array( 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J',  'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T',  'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
		$max_chars = count($chars) - 1;
		for($i = 0; $i < $num; $i++){
	 		$code = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $code . $chars[rand(0, $max_chars)];
		}
		return $code;
	}
	
	function createAdvPositionList(){
		return array(
			'left'=>'BÃƒÆ’Ã‚Âªn trÃƒÆ’Ã‚Â¡i',
			'right'=>'BÃƒÆ’Ã‚Âªn phÃƒÂ¡Ã‚ÂºÃ‚Â£i',
			'middle'=>'ÃƒÂ¡Ã‚Â»Ã…Â¾ giÃƒÂ¡Ã‚Â»Ã‚Â¯a'
		);
	}
	
	/**
	* Hien thi cac file flash
	*/
	function playFlashFile($full_name, $full_path=null){		
		list($width,$height,$imtype,$attr)=@getimagesize($full_path);
		$fixed_width = 180;
		if($width > $fixed_width){
			$height	= ($fixed_width*$height)/$width;
			$width	= $fixed_width;
		}
		
		$flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
			width="'.$width.'" height="'.$height.'">
			<param name="movie" value="'.$full_name.'" />
			<param name="quality" value="high" />
			<embed src="'.$full_name.'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
					type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'"></embed>
		</object>';
		
		return $flash;
	}

	function createAdvTypeList(){
		return array(
			'image'=>'File hÃƒÆ’Ã‚Â¬nh',
			'flash'=>'File flash'
		);
	}
	
	function createPageList(){
		return array(
			'home'=>'Trang chÃƒÂ¡Ã‚Â»Ã‚Â§',
			'products'=>'SÃƒÂ¡Ã‚ÂºÃ‚Â£n phÃƒÂ¡Ã‚ÂºÃ‚Â©m',
			'components'=>'Linh kiÃƒÂ¡Ã‚Â»Ã¢â‚¬Â¡n',
			'news'=>'Tin tÃƒÂ¡Ã‚Â»Ã‚Â©c',
			'files_dowloads'=>'File download',
			'contact'=>'LiÃƒÆ’Ã‚Âªn hÃƒÂ¡Ã‚Â»Ã¢â‚¬Â¡'
		);
	}
	
	function getConfigType(){
		return array(
			'string'=>'string',
			'int'=>'int',
			'text'=>'text',			
		);
	}
	
	 function replaceUnicodeChar($text="",$special="-"){
		$finds=array('Ã¡','Ã ','áº£','Ã£','áº¡','Äƒ','áº¯','áº±','áº³','áºµ','áº·','Ã¢','áº¥','áº§','áº©','áº«','áº­');
		$text=str_replace($finds, 'a', $text);
		$finds=array('Ã�','Ã€','áº¢','Ãƒ','áº ','Ä‚','áº®','áº°','áº²','áº´','áº¶','Ã‚','áº¤','áº¦','áº¨','áºª','áº¬');
		$text=str_replace($finds, 'A', $text);
		$finds=array('Ã³','Ã²','á»�','Ãµ','á»�','Æ¡','á»›','á»�','á»Ÿ','á»¡','á»£','Ã´','á»‘','á»“','á»•','á»—','á»™');
		$text=str_replace($finds, 'o', $text);
		$finds=array('Ã“','Ã’','á»Ž','Ã•','á»Œ','Æ ','á»š','á»œ','á»ž','á» ','á»¢','Ã”','á»�','á»’','á»”','á»–','á»˜');
		$text=str_replace($finds, 'O', $text);		
		$finds=array('Ã©','Ã¨','áº»','áº½','áº¹','Ãª','áº¿','á»�','á»ƒ','á»…','á»‡');		
		$text=str_replace($finds, 'e', $text);
		$finds=array('Ã‰','Ãˆ','áºº','áº¼','áº¸','ÃŠ','áº¾','á»€','á»‚','á»„','á»†');		
		$text=str_replace($finds, 'E', $text);
		$finds=array('Ãº','Ã¹','á»§','Å©','á»¥','Æ°','á»©','á»«','á»­','á»¯','á»±');		
		$text=str_replace($finds, 'u', $text);
		$finds=array('Ãš','Ã™','á»¦','Å¨','á»¤','Æ¯','á»¨','á»ª','á»¬','á»®','á»°');		
		$text=str_replace($finds, 'U', $text);
		$finds=array('Ã­','Ã¬','á»‰','Ä©','á»‹');		
		$text=str_replace($finds, 'i', $text);
		$finds=array('Ã�','ÃŒ','á»ˆ','Ä¨','á»Š');		
		$text=str_replace($finds, 'I', $text);
		$finds=array('Ã½','á»³','á»·','á»¹','á»µ');		
		$text=str_replace($finds, 'y', $text);
		$finds=array('Ã�','á»²','á»¶','á»¸','á»´');		
		$text=str_replace($finds, 'Y', $text);
		$finds=array('Ä‘');		
		$text=str_replace($finds, 'd', $text);
		$finds=array('Ä�');		
		$text=str_replace($finds, 'D', $text);	

		$text= preg_replace('/[^a-zA-Z0-9]/i', $special, $text);
		$text= preg_replace('/-+/i', $special, $text);
		return $text;
	
	}
	
	function translateWord($value){	
		#---------------------------------SPECIAL		
		$value = str_replace("&quot;","", $value);		
		$value = str_replace(".","", $value);		
		$value = str_replace("=","", $value);		
		$value = str_replace("+","", $value);		
		$value = str_replace("!","", $value);		
		$value = str_replace("@","", $value);		
		$value = str_replace("#","", $value);		
		$value = str_replace("$","", $value);		
		$value = str_replace("%","", $value);		
		$value = str_replace("^","", $value);		
		$value = str_replace("&","", $value);		
		$value = str_replace("*","", $value);		
		$value = str_replace("(","", $value);		
		$value = str_replace(")","", $value);		
		$value = str_replace("`","", $value);		
		$value = str_replace("~","", $value);		
		$value = str_replace(",","", $value);	
		$value = str_replace("/","", $value);		
		$value = str_replace("\\","", $value);		
		$value = str_replace('"',"", $value);		
		$value = str_replace("'","", $value);		
		$value = str_replace(":","", $value);		
		$value = str_replace(";","", $value);		
		$value = str_replace("|","", $value);		
		$value = str_replace("[","", $value);		
		$value = str_replace("]","", $value);		
		$value = str_replace("{","", $value);		
		$value = str_replace("}","", $value);		
		$value = str_replace("(","", $value);		
		$value = str_replace(")","", $value);			
		$value = str_replace("?","", $value);	
		#---------------------------------a^	
		$value = str_replace("ÃƒÆ’Ã‚Â¢", "a", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¥", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â§", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â©", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â«", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â­", "a", $value);	
		#---------------------------------A^
		$value = str_replace("ÃƒÆ’Ã¢â‚¬Å¡", "a", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¤", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¦", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¨", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Âª", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¬", "a", $value);	
		#---------------------------------a	
		$value = str_replace("ÃƒÆ’Ã‚Â¡", "a", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Â ", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â£", "a", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Â£", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¡", "a", $value);	
		#---------------------------------A	
		$value = str_replace("ÃƒÆ’Ã¯Â¿Â½", "a", $value);	
		$value = str_replace("ÃƒÆ’Ã¢â€šÂ¬", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¢", "a", $value);	
		$value = str_replace("ÃƒÆ’Ã†â€™", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â ", "a", $value);	
		#---------------------------------a(	
		$value = str_replace("Ãƒâ€žÃ†â€™", "a", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¯", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â±", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â³", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Âµ", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â·", "a", $value);	
		#---------------------------------A(	
		$value = str_replace("Ãƒâ€žÃ¢â‚¬Å¡", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â®", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â°", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â²", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â´", "a", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¶", "a", $value);	
		$value = str_replace("Ãƒâ€žÃ¢â‚¬Å¡", "a", $value);	
		#---------------------------------e^	
		$value = str_replace("ÃƒÆ’Ã‚Âª", "e", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¿", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¯Â¿Â½", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã†â€™", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Â¦", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Â¡", "e", $value);	
		#---------------------------------E^	
		$value = str_replace("ÃƒÆ’Ã…Â ", "e", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¾", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â€šÂ¬", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Å¡", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Å¾", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Â ", "e", $value);	
		#---------------------------------e	
		$value = str_replace("ÃƒÆ’Ã‚Â©", "e", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Â¨", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â»", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â½", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¹", "e", $value);	
		#---------------------------------E	
		$value = str_replace("ÃƒÆ’Ã¢â‚¬Â°", "e", $value);	
		$value = str_replace("ÃƒÆ’Ã‹â€ ", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Âº", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¼", "e", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚ÂºÃ‚Â¸", "e", $value);	
		#---------------------------------i	
		$value = str_replace("ÃƒÆ’Ã‚Â­", "i", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Â¬", "i", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Â°", "i", $value);	
		$value = str_replace("Ãƒâ€žÃ‚Â©", "i", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Â¹", "i", $value);	
		#---------------------------------I	
		$value = str_replace("ÃƒÆ’Ã¯Â¿Â½", "i", $value);	
		$value = str_replace("ÃƒÆ’Ã¯Â¿Â½", "i", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‹â€ ", "i", $value);	
		$value = str_replace("Ãƒâ€žÃ‚Â¨", "i", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…Â ", "i", $value);	
		#---------------------------------o^	
		$value = str_replace("ÃƒÆ’Ã‚Â´", "o", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Ëœ", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Å“", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Â¢", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬â€�", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â€žÂ¢", "o", $value);	
		#---------------------------------O^	
		$value = str_replace("ÃƒÆ’Ã¢â‚¬ï¿½", "o", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¯Â¿Â½", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬â„¢", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬ï¿½", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬â€œ", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‹Å“", "o", $value);	
		#---------------------------------o*	
		$value = str_replace("Ãƒâ€ Ã‚Â¡", "o", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¢â‚¬Âº", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¯Â¿Â½", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…Â¸", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¡", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â£", "o", $value);	
		#---------------------------------O*	
		$value = str_replace("Ãƒâ€ Ã‚Â ", "o", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…Â¡", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…â€œ", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…Â¾", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â ", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¢", "o", $value);	
		#---------------------------------u*	
		$value = str_replace("Ãƒâ€ Ã‚Â°", "u", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â©", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â«", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â­", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¯", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â±", "u", $value);	
		#---------------------------------U*	
		$value = str_replace("Ãƒâ€ Ã‚Â¯", "u", $value);		
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¨", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Âª", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¬", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â®", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â°", "u", $value);	
		#---------------------------------y	
		$value = str_replace("ÃƒÆ’Ã‚Â½", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â³", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â·", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¹", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Âµ", "y", $value);
		#---------------------------------Y	
		$value = str_replace("ÃƒÆ’Ã¯Â¿Â½", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â²", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¶", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¸", "y", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â´", "y", $value);	
		#---------------------------------DD	
			$value = str_replace("Ãƒâ€žÃ¯Â¿Â½", "d", $value);			
			$value = str_replace("Ãƒâ€žÃ¢â‚¬Ëœ", "d", $value);	
		#---------------------------------o	
		$value = str_replace("ÃƒÆ’Ã‚Â³", "o", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Â²", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¯Â¿Â½", "o", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Âµ", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã¯Â¿Â½", "o", $value);	
		#---------------------------------O	
		$value = str_replace("ÃƒÆ’Ã¢â‚¬Å“", "o", $value);	
		$value = str_replace("ÃƒÆ’Ã¢â‚¬â„¢", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…Â½", "o", $value);	
		$value = str_replace("ÃƒÆ’Ã¢â‚¬Â¢", "o", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã…â€™", "o", $value);	
		#---------------------------------u	
		$value = str_replace("ÃƒÆ’Ã‚Âº", "u", $value);	
		$value = str_replace("ÃƒÆ’Ã‚Â¹", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â§", "u", $value);	
		$value = str_replace("Ãƒâ€¦Ã‚Â©", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¥", "u", $value);	
		#---------------------------------U	
		$value = str_replace("ÃƒÆ’Ã…Â¡", "u", $value);	
		$value = str_replace("ÃƒÆ’Ã¢â€žÂ¢", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¦", "u", $value);	
		$value = str_replace("Ãƒâ€¦Ã‚Â¨", "u", $value);	
		$value = str_replace("ÃƒÂ¡Ã‚Â»Ã‚Â¤", "u", $value);	
		#---------------------------------	
		return $value;
		
	
	} 
	
	function datevie($strFormat='',$time=null ){
		$time=strtotime($time);
		if(intval($time))$time=$time+GMT;
		//t(date($strFormat,$time));
		$time=getdate ($time);
		//t($time);
		if(isset($time['weekday'])){
			switch($time['weekday']){
				case 'Sunday':$time['weekday']='Chá»§ nháº­t';break;
				case 'Monday':$time['weekday']='Thá»© hai';break;
				case 'Tuesday':$time['weekday']='Thá»© ba';break;
				case 'Wednesday':$time['weekday']='Thá»© tÆ°';break;
				case 'Thursday':$time['weekday']='Thá»© nÄƒm';break;
				case 'Friday':$time['weekday']='Thá»© sÃ¡u';break;
				case 'Saturday':$time['weekday']='Thá»© báº£y';break;
			}
		}
		
		if(isset($time['month'])){
			switch($time['month']){
				case 'January':$time['month']='ThÃ¡ng giÃªng';break;
				case 'Febuary':$time['month']='ThÃ¡ng hai';break;
				case 'March':$time['month']='ThÃ¡ng ba';break;
				case 'April':$time['month']='ThÃ¡ng tÆ°';break;
				case 'May':$time['month']='ThÃ¡ng nÄƒm';break;
				case 'June':$time['month']='ThÃ¡ng sÃ¡u';break;
				case 'July':$time['month']='ThÃ¡ng báº£y';break;
				case 'August':$time['month']='ThÃ¡ng tÃ¡m';break;
				case 'September':$time['month']='ThÃ¡ng chÃ­n';break;
				case 'October':$time['month']='ThÃ¡ng mÆ°á»�i';break;
				case 'November':$time['month']='ThÃ¡ng mÆ°á»�i má»™t';break;
				case 'December':$time['month']='ThÃ¡ng cháº¡p';break;
			}
		}
		
		$strFormat=str_replace('D',$time['weekday'],$strFormat);
		$strFormat=str_replace('M',$time['month'],$strFormat);
		$strFormat=str_replace('m',$time['mon'],$strFormat);
		$strFormat=str_replace('d',$time['mday'],$strFormat);
		$strFormat=str_replace('Y',$time['year'],$strFormat);
		return $strFormat;
		
	}
	
}
?>
